#ifndef LIB_UTILS_UI_RESIZEHANDLE_H_
#define LIB_UTILS_UI_RESIZEHANDLE_H_

#include "utils/utils_global.h"
#include <QMouseEvent>
#include <QFrame>

namespace TWUtils {
namespace UI {

	class TWUTILS_EXPORT ResizeHandle: public QFrame
	{
		Q_OBJECT
		Q_DISABLE_COPY(ResizeHandle)
		public:
			enum ResizeMode
			{
				Vertical = 1,Horizontal,Diagonal
			};
			explicit ResizeHandle(QWidget* w = 0):QFrame(w),	target(0){}

			void setResizeTarget(QWidget* t){target = t;}
			void setResizeMode(ResizeMode mode);
		signals:
			void sizeChanged(int height,int width);
			void mouseReleased();
		protected:
			void mouseMoveEvent(QMouseEvent* event);
			void mousePressEvent(QMouseEvent* event);
			void mouseReleaseEvent(QMouseEvent* event);
		private:
			QWidget* target;
			ResizeMode e_resizeMode;
			bool dragStarted;
			QPoint mousePressGPos;
			QPoint moveDistance;
	};
}
}
#endif /* LIB_TWCORE_INTERNAL_RESIZEHANDLE_H_ */
